package com.ifox.hgx.spring.annotation.test;

import com.ifox.hgx.spring.annotation.bean.Boss;
import com.ifox.hgx.spring.annotation.bean.Car;
import com.ifox.hgx.spring.annotation.bean.Color;
import com.ifox.hgx.spring.annotation.config.MainConfigOfAutowired;
import com.ifox.hgx.spring.annotation.controller.PersonController;
import com.ifox.hgx.spring.annotation.dao.PersonRepository;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class IOCTest_Autowired {

    @Test
    public void test01() {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(MainConfigOfAutowired.class);

        PersonController personController = applicationContext.getBean(PersonController.class);
        System.out.println(personController);

//        PersonRepository personRepository = applicationContext.getBean(PersonRepository.class);
//        System.out.println(personRepository);

		Boss boss = applicationContext.getBean(Boss.class);
		System.out.println(boss);
		Car car = applicationContext.getBean(Car.class);
		System.out.println(car);

        Color color = applicationContext.getBean(Color.class);
        System.out.println(color);
        System.out.println(applicationContext);
        applicationContext.close();
    }

}
